//
// Created by 17775 on 2024/11/15.
//

#ifndef RAYCI_DIVERGENCE_VIEW_H
#define RAYCI_DIVERGENCE_VIEW_H

#include <QDockWidget>
#include <QGridLayout>
#include "../Common/commonchart.h"
#include "../qcustomplot.h"
#include "../Common/common_2dview.h"
#include "divergence_result.h"
#include "../RayCi/Divergence.h"


QT_BEGIN_NAMESPACE
namespace Ui { class Divergence_View; }
QT_END_NAMESPACE

class Divergence_View : public QDockWidget {
Q_OBJECT

signals:
    void sendAutoContrast(bool isAuto);
    void stopDivergenceThread();
    void exportDivergence();
    void showDivergence2DView();
    void DivergenceViewClicked();
    void DivergenceClicked();

public slots:
    void setAutoContrast();

public:
    explicit Divergence_View(QWidget *parent = nullptr);
    ~Divergence_View() override;
    void setWindowTitleName(const QString& name);

    void mousePressEvent(QMouseEvent *event);

    void setAuto(bool bAuto);
    Common_2DView* getComm2DView() {
        return common2DView;
    }
    void updateResult(DivergenceResult result);

private:
    Ui::Divergence_View *ui;
    QWidget* menuPanel = nullptr;
    QWidget* lutPanel = nullptr;
    QVBoxLayout* menuLayout = nullptr;
    QVBoxLayout* lutLayout = nullptr;
    QWidget* centralWidget = nullptr;
    QHBoxLayout* mainLayout = nullptr;
    QPushButton* btnSave = nullptr;
    QPushButton* btnSaveAs = nullptr;
    QPushButton* btnAOIAdjustment = nullptr;
    QPushButton* btn2DView = nullptr;
    QPushButton* btn3DView = nullptr;
    QPushButton* btnFitView = nullptr;
    QPushButton* btnResult = nullptr;
    QPushButton* btnReport = nullptr;
    QCheckBox* cBox_Auto = nullptr;
    QSplitter* mainSplitter = nullptr;
    QSplitter* leftSplitter = nullptr;
    QSplitter* rightSplitter = nullptr;

    Common_2DView* common2DView = nullptr;
    Divergence_Result* divergenceResult = nullptr;
    CommonChart* _3DChart = nullptr;
    CommonChart* fitChart = nullptr;
    void closeEvent(QCloseEvent *event) override;

};


#endif //RAYCI_DIVERGENCE_VIEW_H